package service.impl;

import net.roarsoftware.lastfm.Authenticator;
import net.roarsoftware.lastfm.Playlist;
import net.roarsoftware.lastfm.Session;
import common.Constants;
import net.roarsoftware.lastfm.Result;

import service.PlayListService;

public class PlayListServiceImpl implements PlayListService {
	
	private static PlayListServiceImpl instance;
	
	public static PlayListServiceImpl getInstance() {
		if (instance == null) {
			instance = new PlayListServiceImpl();
		}
		return instance;
	}
	
	private PlayListServiceImpl() {
		
	}

	public Playlist create(String title, String description, Session session) {
		return Playlist.create(title, description, session);
	}
	
	public Result addTrack(String artist, String track, Session session, int playlistId) {
		return Playlist.addTrack(playlistId, artist, track, session);				
	}
	
	public Playlist getPlaylist(int playlistId) {
		return Playlist.fetchUserPlaylist(playlistId, Constants.API_KEY);
	}
	
	public Session createSession(String user, String passwd) {
		return Authenticator.getMobileSession(user, passwd, Constants.API_KEY, Constants.SECRET_API_KEY);
	}
}
